﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace AFCEPF.BankApplication.BLL
{
    /// <summary>
    /// Visitor that will withdraw 1 % of an 
    /// account balance, when a withdrawal is 
    /// performed on a negative balanced account.
    /// </summary>
    public class NegativeBalanceTaxVisitor : IVisitor
    {
        #region IVisitor Members

        /// <summary>
        /// Visits the specified visitable.
        /// </summary>
        /// <param name="visitable">The visitable.</param>
        public void Visit(IVisitable visitable)
        {
            // Let's cast back to AccountBase..
            AccountBase account = visitable as AccountBase;

            // and withdraw 1 % of the negative balance 
            // amount..
            Debug.Assert(account != null, "account != null");
            account.Balance -= -(account.Balance * 0.01);

        }

        #endregion
    }
}
